'use strict';
const dayjs = require('dayjs');
module.exports = app => {
  const { STRING, INTEGER, DATE} = app.Sequelize;
    return app.model.define(
      'energyTimeData',
      {
          id: {type: INTEGER, primaryKey: true, autoIncrement: true},
          name: {
              type: DATE,
              get() {
                  return dayjs(this.getDataValue('name')).format('YYYY-MM-DD HH:mm:ss')
              },
          },
          value: STRING(255),
      },
      {
          tableName: 'energy_time_data',
          timestamps: true, // 启用时间戳(createdAt, updatedAt)
          updatedAt: false, // 不想要 updatedAt
          createdAt: false, // 想要  createdAt 但是希望名称叫做 created_at
      }
  );
};
